#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <vector>

using namespace std;

class Solution {
   public:
    int singleNumber(vector<int>& nums) {
        int carry[32];
        memset(carry, 0, sizeof(int) * 32);
        for (int i = 0; i < nums.size(); i++) {
            for (int j = 0; j < 32; j++) {
                carry[31 - j] += (nums[i] & 1);
                nums[i] = nums[i] >> 1;
                if (nums[i] == 0)
                    break;
            }
        }
        int ret = 0;
        for (int i = 0; i < 32; i++) {
            ret = ret << 1;
            ret = ret | (carry[i] % 3 == 0 ? 0 : 1);
        }
        return ret;
    }
};

int main() {
    vector<int> t;
    t.push_back(3);
    t.push_back(3);
    t.push_back(3);
    t.push_back(4);
    int i = Solution().singleNumber(t);
    return 0;
}